package com.course.controller;

import com.course.pojo.Teacher;
import com.course.service.TeacherService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TeacherController {

    private TeacherService teacherService;

    @RequestMapping(value = "teacher_login",method = RequestMethod.POST)
    @ResponseBody
    @PostMapping("/teacher_login")
    public String login(String account,String password){
        Teacher teacher = teacherService.login(account, password);
        teacher.setPassword("");
        if(teacher == null){
            json.put("code",400);
            json.put("teacher","");
        }else {
            json.put("code",200);
            json.put("teacher",teacher);
        }
        return json.toJSONString();
    }
}